#ifndef _BUFFER_H
#define _BUFFER_H

#define FRAMEHEAD_SIZE 6//用户通信协议中帧头大小
class Buffer
{
public:
    Buffer(int tatol = 65536)
    {
        read_index = 0;
        write_index = 0;
        buffer_size = tatol;
        if(buffer_size < 0)
        {
            printf("in Buffer err : 缓冲区大小不能小于０\n");
        }
        data = new char[buffer_size];
        if(data == NULL)
        {
            printf("make buffer filed\n");
        }
    }
    ~Buffer()
    {

    }
    char *getframe(char *data_buf);

    bool add(char *buf,int buf_len);
private:
    bool read(char *buf,int read_len);
    bool look(char *buf,int read_len);

private:
    int read_index;         //读索引
    int write_index;          //写索引
    int buffer_size;
    char *data;
};






#endif // _BUFFER_H
